package com.chushouya.controller.manager.admin;


import com.chushouya.common.constant.ServiceType;
import com.general.framework.core.schema.PageResult;
import com.general.framework.core.schema.Response;
import com.chushouya.manager.dto.admin.partner.PartnerUserListDTO;
import com.chushouya.manager.dto.admin.partner.PartnerUserQuery;
import com.chushouya.manager.dto.admin.partner.PartnerUserSaveDTO;
import com.chushouya.manager.service.admin.PartnerUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping(ServiceType.PLATFORM + "/partnerUser")
@Api(tags = ServiceType.PLATFORM + "渠道员工账号管理")
public class PartnerUserController {

    @Resource
    private PartnerUserService partnerUserService;

    @ApiOperation("合作商账号列表")
    @GetMapping("/list")
    public Response<PageResult<PartnerUserListDTO>> list(PartnerUserQuery query) {
        return Response.success(partnerUserService.selectPageResult(query));
    }

    @ApiOperation("保存合作商账号")
    @PostMapping("/add")
    public Response<String> add(@Validated @RequestBody PartnerUserSaveDTO partnerUserSave) {
        return Response.success(partnerUserService.add(partnerUserSave));
    }


    @ApiOperation("更新合作商账号")
    @PostMapping("/edit")
    public Response<String> edit(@Validated @RequestBody PartnerUserSaveDTO partnerUserSave) {
        return Response.success(partnerUserService.edit(partnerUserSave));
    }

    @ApiOperation("状态修改")
    @PostMapping("/updateStatus")
    public Response<Void> updateStatus(Long partnerUserId, Integer status) {
        partnerUserService.updateStatus(partnerUserId, status);
        return Response.success();
    }

}
